Imports System.Data
Partial Class Admin_frmTabScheme
    Inherits System.Web.UI.Page
    Dim conn As New SqlString()
    Dim _BO As New Bo()
    Dim _SchemeVO As New SchemeVo()
    Dim _EmployeeId As String
    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Try
            _SchemeVO.SchemeId = txtSchemeId.Text
            _SchemeVO.Description = txtDiscription.Text
            _SchemeVO.Discount = txtDiscount.Text


            _BO.InsertScheme(_SchemeVO)
            ClearAll()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Public Sub ClearAll()
        txtSchemeId.Text = ""
        txtDiscription.Text = ""
        txtDiscount.Text = ""
        
        MsgBox("Scheme Inserted")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        _EmployeeId = Session("EmpId")
        If _EmployeeId = "" Then
            Response.Redirect("../Client/frmLogin.aspx")
        End If
        If Not Page.IsPostBack Then
            panel2.Visible = False
            panel4.Visible = False
            GridData()
        End If

    End Sub
    Sub GridData()
        Dim dtScheme As DataTable
        dtScheme = _BO.getSchemeDetails()
        gdScheme.DataSource = dtScheme
        gdScheme.DataBind()
    End Sub
    Protected Sub gdScheme_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles gdScheme.EditCommand
        Session("EmpId") = _EmployeeId
        Response.Redirect("frmModifyScheme.aspx?SchemeId=" & e.Item.Cells(0).Text)
    End Sub

    Protected Sub gdScheme_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles gdScheme.DeleteCommand
        _BO.DeleteScheme(e.Item.Cells(0).Text)
        Response.Redirect("frmTabScheme.aspx")
    End Sub
    Protected Sub ImageAdd_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageAdd.Click
        panel2.Visible = True
        panel4.Visible = False
    End Sub

    Protected Sub ImageEdit_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageEdit.Click
        panel2.Visible = False
        panel4.Visible = True
        GridData()
    End Sub
    Protected Sub gdScheme_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles gdScheme.PageIndexChanged
        gdScheme.CurrentPageIndex = e.NewPageIndex
        GridData()
    End Sub

    Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtSchemeId.Text = ""
        txtDiscription.Text = ""
        txtDiscount.Text = ""
      
    End Sub
End Class